3.252 \(\int (a+b \tan ^2(c+d x))^2 \, dx\)

Optimal. Leaf size=46 \[ \frac{b (2 a-b) \tan (c+d x)}{d}+x (a-b)^2+\frac{b^2 \tan ^3(c+d x)}{3 d} \]

[Out]

(a - b)^2*x + ((2*a - b)*b*Tan[c + d*x])/d + (b^2*Tan[c + d*x]^3)/(3*d)

________________________________________________________________________________________

Rubi [A]  time = 0.0312722, antiderivative size = 46, normalized size of antiderivative = 1., number of steps used = 4, number of rules used = 3, integrand size = 14, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.214, Rules used = {3661, 390, 203} \[ \frac{b (2 a-b) \tan (c+d x)}{d}+x (a-b)^2+\frac{b^2 \tan ^3(c+d x)}{3 d} \]

Antiderivative was successfully verified.

[In]

Int[(a + b*Tan[c + d*x]^2)^2,x]

[Out]

(a - b)^2*x + ((2*a - b)*b*Tan[c + d*x])/d + (b^2*Tan[c + d*x]^3)/(3*d)

Rule 3661

Int[((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_), x_Symbol] :> With[{ff = FreeFactors[Tan[e + f*x]
, x]}, Dist[(c*ff)/f, Subst[Int[(a + b*(ff*x)^n)^p/(c^2 + ff^2*x^2), x], x, (c*Tan[e + f*x])/ff], x]] /; FreeQ
[{a, b, c, e, f, n, p}, x] && (IntegersQ[n, p] || IGtQ[p, 0] || EqQ[n^2, 4] || EqQ[n^2, 16])

Rule 390

Int[((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_))^(q_), x_Symbol] :> Int[PolynomialDivide[(a + b*x^n)
^p, (c + d*x^n)^(-q), x], x] /; FreeQ[{a, b, c, d}, x] && NeQ[b*c - a*d, 0] && IGtQ[n, 0] && IGtQ[p, 0] && ILt
Q[q, 0] && GeQ[p, -q]

Rule 203

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1*ArcTan[(Rt[b, 2]*x)/Rt[a, 2]])/(Rt[a, 2]*Rt[b, 2]), x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rubi steps

\begin{align*} \int \left (a+b \tan ^2(c+d x)\right )^2 \, dx &=\frac{\operatorname{Subst}\left (\int \frac{\left (a+b x^2\right )^2}{1+x^2} \, dx,x,\tan (c+d x)\right )}{d}\\ &=\frac{\operatorname{Subst}\left (\int \left ((2 a-b) b+b^2 x^2+\frac{(a-b)^2}{1+x^2}\right ) \, dx,x,\tan (c+d x)\right )}{d}\\ &=\frac{(2 a-b) b \tan (c+d x)}{d}+\frac{b^2 \tan ^3(c+d x)}{3 d}+\frac{(a-b)^2 \operatorname{Subst}\left (\int \frac{1}{1+x^2} \, dx,x,\tan (c+d x)\right )}{d}\\ &=(a-b)^2 x+\frac{(2 a-b) b \tan (c+d x)}{d}+\frac{b^2 \tan ^3(c+d x)}{3 d}\\ \end{align*}

Mathematica [A]  time = 0.573146, size = 73, normalized size = 1.59 \[ \frac{\tan (c+d x) \left (b \left (6 a-b \left (3-\tan ^2(c+d x)\right )\right )+\frac{3 (a-b)^2 \tanh ^{-1}\left (\sqrt{-\tan ^2(c+d x)}\right )}{\sqrt{-\tan ^2(c+d x)}}\right )}{3 d} \]

Antiderivative was successfully verified.

[In]

Integrate[(a + b*Tan[c + d*x]^2)^2,x]

[Out]

(Tan[c + d*x]*((3*(a - b)^2*ArcTanh[Sqrt[-Tan[c + d*x]^2]])/Sqrt[-Tan[c + d*x]^2] + b*(6*a - b*(3 - Tan[c + d*
x]^2))))/(3*d)

________________________________________________________________________________________

Maple [A]  time = 0.004, size = 87, normalized size = 1.9 \begin{align*}{\frac{{b}^{2} \left ( \tan \left ( dx+c \right ) \right ) ^{3}}{3\,d}}+2\,{\frac{a\tan \left ( dx+c \right ) b}{d}}-{\frac{{b}^{2}\tan \left ( dx+c \right ) }{d}}+{\frac{\arctan \left ( \tan \left ( dx+c \right ) \right ){a}^{2}}{d}}-2\,{\frac{\arctan \left ( \tan \left ( dx+c \right ) \right ) ab}{d}}+{\frac{\arctan \left ( \tan \left ( dx+c \right ) \right ){b}^{2}}{d}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+b*tan(d*x+c)^2)^2,x)

[Out]

1/3*b^2*tan(d*x+c)^3/d+2/d*tan(d*x+c)*a*b-b^2*tan(d*x+c)/d+1/d*arctan(tan(d*x+c))*a^2-2/d*arctan(tan(d*x+c))*a
*b+1/d*arctan(tan(d*x+c))*b^2

________________________________________________________________________________________

Maxima [A]  time = 1.69442, size = 78, normalized size = 1.7 \begin{align*} a^{2} x - \frac{2 \,{\left (d x + c - \tan \left (d x + c\right )\right )} a b}{d} + \frac{{\left (\tan \left (d x + c\right )^{3} + 3 \, d x + 3 \, c - 3 \, \tan \left (d x + c\right )\right )} b^{2}}{3 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c)^2)^2,x, algorithm="maxima")

[Out]

a^2*x - 2*(d*x + c - tan(d*x + c))*a*b/d + 1/3*(tan(d*x + c)^3 + 3*d*x + 3*c - 3*tan(d*x + c))*b^2/d

________________________________________________________________________________________

Fricas [A]  time = 1.33751, size = 117, normalized size = 2.54 \begin{align*} \frac{b^{2} \tan \left (d x + c\right )^{3} + 3 \,{\left (a^{2} - 2 \, a b + b^{2}\right )} d x + 3 \,{\left (2 \, a b - b^{2}\right )} \tan \left (d x + c\right )}{3 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c)^2)^2,x, algorithm="fricas")

[Out]

1/3*(b^2*tan(d*x + c)^3 + 3*(a^2 - 2*a*b + b^2)*d*x + 3*(2*a*b - b^2)*tan(d*x + c))/d

________________________________________________________________________________________

Sympy [A]  time = 0.396985, size = 68, normalized size = 1.48 \begin{align*} \begin{cases} a^{2} x - 2 a b x + \frac{2 a b \tan{\left (c + d x \right )}}{d} + b^{2} x + \frac{b^{2} \tan ^{3}{\left (c + d x \right )}}{3 d} - \frac{b^{2} \tan{\left (c + d x \right )}}{d} & \text{for}\: d \neq 0 \\x \left (a + b \tan ^{2}{\left (c \right )}\right )^{2} & \text{otherwise} \end{cases} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c)**2)**2,x)

[Out]

Piecewise((a**2*x - 2*a*b*x + 2*a*b*tan(c + d*x)/d + b**2*x + b**2*tan(c + d*x)**3/(3*d) - b**2*tan(c + d*x)/d
, Ne(d, 0)), (x*(a + b*tan(c)**2)**2, True))

________________________________________________________________________________________

Giac [B]  time = 1.46966, size = 485, normalized size = 10.54 \begin{align*} \frac{3 \, a^{2} d x \tan \left (d x\right )^{3} \tan \left (c\right )^{3} - 6 \, a b d x \tan \left (d x\right )^{3} \tan \left (c\right )^{3} + 3 \, b^{2} d x \tan \left (d x\right )^{3} \tan \left (c\right )^{3} - 9 \, a^{2} d x \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + 18 \, a b d x \tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 9 \, b^{2} d x \tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 6 \, a b \tan \left (d x\right )^{3} \tan \left (c\right )^{2} + 3 \, b^{2} \tan \left (d x\right )^{3} \tan \left (c\right )^{2} - 6 \, a b \tan \left (d x\right )^{2} \tan \left (c\right )^{3} + 3 \, b^{2} \tan \left (d x\right )^{2} \tan \left (c\right )^{3} + 9 \, a^{2} d x \tan \left (d x\right ) \tan \left (c\right ) - 18 \, a b d x \tan \left (d x\right ) \tan \left (c\right ) + 9 \, b^{2} d x \tan \left (d x\right ) \tan \left (c\right ) - b^{2} \tan \left (d x\right )^{3} + 12 \, a b \tan \left (d x\right )^{2} \tan \left (c\right ) - 9 \, b^{2} \tan \left (d x\right )^{2} \tan \left (c\right ) + 12 \, a b \tan \left (d x\right ) \tan \left (c\right )^{2} - 9 \, b^{2} \tan \left (d x\right ) \tan \left (c\right )^{2} - b^{2} \tan \left (c\right )^{3} - 3 \, a^{2} d x + 6 \, a b d x - 3 \, b^{2} d x - 6 \, a b \tan \left (d x\right ) + 3 \, b^{2} \tan \left (d x\right ) - 6 \, a b \tan \left (c\right ) + 3 \, b^{2} \tan \left (c\right )}{3 \,{\left (d \tan \left (d x\right )^{3} \tan \left (c\right )^{3} - 3 \, d \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + 3 \, d \tan \left (d x\right ) \tan \left (c\right ) - d\right )}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c)^2)^2,x, algorithm="giac")

[Out]

1/3*(3*a^2*d*x*tan(d*x)^3*tan(c)^3 - 6*a*b*d*x*tan(d*x)^3*tan(c)^3 + 3*b^2*d*x*tan(d*x)^3*tan(c)^3 - 9*a^2*d*x
*tan(d*x)^2*tan(c)^2 + 18*a*b*d*x*tan(d*x)^2*tan(c)^2 - 9*b^2*d*x*tan(d*x)^2*tan(c)^2 - 6*a*b*tan(d*x)^3*tan(c
)^2 + 3*b^2*tan(d*x)^3*tan(c)^2 - 6*a*b*tan(d*x)^2*tan(c)^3 + 3*b^2*tan(d*x)^2*tan(c)^3 + 9*a^2*d*x*tan(d*x)*t
an(c) - 18*a*b*d*x*tan(d*x)*tan(c) + 9*b^2*d*x*tan(d*x)*tan(c) - b^2*tan(d*x)^3 + 12*a*b*tan(d*x)^2*tan(c) - 9
*b^2*tan(d*x)^2*tan(c) + 12*a*b*tan(d*x)*tan(c)^2 - 9*b^2*tan(d*x)*tan(c)^2 - b^2*tan(c)^3 - 3*a^2*d*x + 6*a*b
*d*x - 3*b^2*d*x - 6*a*b*tan(d*x) + 3*b^2*tan(d*x) - 6*a*b*tan(c) + 3*b^2*tan(c))/(d*tan(d*x)^3*tan(c)^3 - 3*d
*tan(d*x)^2*tan(c)^2 + 3*d*tan(d*x)*tan(c) - d)